<%@ page import="java.io.File" %>
<%@ page import="TeachLesson.CourseWork.CourseWorkDao" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="TeachLesson.CourseWork.CourseWorkEnity" %>
<%@ page import="java.net.URLEncoder" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/8/23
  Time: 8:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>课程作业管理</title>
    <link href="/SystemerNav/SystemerNav.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" href="https://unpkg.com/purecss@1.0.0/build/pure-min.css" integrity="sha384-CCTZv2q9I9m3UOxRLaJneXrrqKwUNOzZ6NGEUMwHtShDJ+nCoiXJCAgi05KfkLGY" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<%
    String workerNo=(String) session.getAttribute("workerNo");
    String courseNo=(String) session.getAttribute("courseNo");
    request.setCharacterEncoding("UTF-8");
    response.setContentType("text/html;charset=UTF-8");
    out.println(workerNo);

    response.setCharacterEncoding("GBK");
    request.setCharacterEncoding("GBK");
    //文件路径
    String pathFile="F:/JWGLXT/web/courseWork/"+workerNo+'/'+courseNo;
    //创建file对象
    File file=new File(pathFile);
    //判断是否存在
    if(!(file.isDirectory() && file.exists())){
        file.mkdirs();                         //如果文件夹不存在,则创建之
    }
%>
<body background="/LoginInterface/loginFace.jpg">
<div class="container">
    <div class="top">
        <div id="navbar" class="collapse navbar-collapse">
            <ul class="nav navbar-nav">
                <li><a href="courseMangement.jsp?workerNo=<%=workerNo%>&courseNo=<%=courseNo%>">首页</a> </li>
                <li><a href="/TeacherServlet/seletIntroduceServlet?workerNo=<%=workerNo%>&courseNo=<%=courseNo%>">课程简介</a> </li>
                <li><a href="AddStudentLesson.jsp">添加学生</a> </li>
                <li><a href="unitStudy.jsp?workerNo=<%=workerNo%>&courseNo=<%=courseNo%>">单元学习</a></li>
                <li><a href="courseWorkMangement.jsp?workerNo=<%=workerNo%>&courseNo=<%=courseNo%>">作业管理</a> </li>
                <li><a href="SolvePro.jsp?workerNo=<%=workerNo%>&courseNo=<%=courseNo%>">答疑讨论</a> </li>
            </ul>
        </div>
        <p></p><p></p><p></p>
        <h4>新添作业</h4><hr>
        <form class="form-horizontal" method="post" enctype="multipart/form-data" action="/TeachLesson/addCourseWorkServlet?" >

                <div class="form-group">
                    <label for="inputEmail3" class="col-sm-2 control-label">作业标题</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" name="title" id="inputEmail3" placeholder="请输入作业标题">
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputPassword3" class="col-sm-2 control-label">提交截止日期</label>
                    <div class="col-sm-10">
                        <input type="datetime-local" class="form-control" name="endTime" id="inputPassword3" placeholder="Password">
                    </div>
                </div>
            <div class="form-group">
                  <label class="col-sm-2 control-label">作业要求描述</label>
                <div class="col-sm-10">
                  <textarea class="form-control" rows="5" name="workDesc"></textarea>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">评分方式</label>
                <div class="col-sm-10">
                <select class="form-control" name="evaluteType">
                    <option value="等级制">等级制(A-E)</option>
                    <option value="打分制">打分制(100分)</option>
                </select>
                </div>
            </div>


            <div class="form-group">
                <div class="col-sm-10">
                <label for="exampleInputFile" class="col-sm-2 control-label">作业附件</label>
                    <div class="col-sm-10">
                <input type="file" id="exampleInputFile" name="t1">
                <p class="help-block">多文件可上传压缩包</p>



                <button type="submit" class="btn btn-default">上传</button>
                </div>
            </div>
            </div>
            <input type="hidden" name="workerNo" value="<%=workerNo%>">
            <input type="hidden" name="courseNo" value="<%=courseNo%>">
            <input type="hidden" name="filePath" value="<%=pathFile%>">
        </form>

    <div class="bottom">
        <table class="table table-hover">
            <tr>
                <td>作业名</td>
                <td>提交截至时间</td>
                <td>评分方式</td>
                <td>详细</td>
                <td>删除</td>
                <td>批改作业</td>
            </tr>
            <%
                CourseWorkDao courseWorkDao=new CourseWorkDao();
                ArrayList<CourseWorkEnity> list=courseWorkDao.getCourseWork(workerNo,courseNo);
                for(CourseWorkEnity temp:list){
                   %>
             <tr>
                <td><%=temp.getTitle()%></td>
                 <td><%=temp.getEndTime()%></td>
                 <td><%=temp.getEvaluteType()%></td>
                 <td>
                    <form action="CourseWorkDetail.jsp" target="_blank">
                        <input type="hidden" name="id" value="<%=temp.getId()%>">
                        <input type="hidden" name="workerNo" value="<%=workerNo%>">
                        <input type="hidden" name="courseNo" value="<%=courseNo%>">
                        <button type="submit" class="btn btn-success">查看详细信息</button>
                    </form>
                 </td>
                 <td>
                     <form action="/TeachLesson/CourseWork/deleteCourseWorksServlet">
                         <input type="hidden" name="id" value="<%=temp.getId()%>">
                         <input type="hidden" name="filePath" value="<%=temp.getFilePath()%>">
                         <input type="hidden" name="workerNo" value="<%=workerNo%>">
                         <input type="hidden" name="courseNo" value="<%=courseNo%>">
                         <button type="submit" class="btn btn-danger">删除</button>
                     </form>
                 </td>
                 <td>
                     <form action="CorrectWork.jsp">
                         <input type="hidden" name="id" value="<%=temp.getId()%>">
                         <input type="hidden" name="workerNo" value="<%=workerNo%>">
                         <input type="hidden" name="courseNo" value="<%=courseNo%>">
                         <button type="submit" class="btn btn-info">批改作业</button>
                     </form>

                 </td>
             </tr>

            <%
                }%>
        </table>
    </div>

</div>
</div>
</body>
</html>
